<?php
class BDO
{
    private $link;
    public function __construct()
    {
        $this->link=$dbh = new PDO('mysql:host=127.0.0.1;dbname=1705php', 'root', 'root');
        $this->link->exec("set names utf8");
        $this->link->setAttribute(PDO::ATTR_ERRMODE,1);
    }
    public function getNamber($table,$where="1")
    {
        if(empty($table) || empty($where))
        {
            return "不能为空";
        }
        $sql="select * from `$table` where $where";
        $res=$this->link->query($sql);
        return $res->rowCount();
    }
    public function getAll($table,$where="1",$limit,$size)
    {
        if(empty($table))
        {
            return "不能为空";
        }
        $sql="select * from `$table` where $where limit $limit,$size";
        $res=$this->link->query($sql);
        return $res->fetchAll(2);
    }
    public function getOne($table,$where="1")
    {
        if(empty($table) || empty($where))
        {
            return "不能为空";
        }
        $sql="select * from `$table` where $where";
        $res=$this->link->query($sql);
        return $res->fetch(2);
    }
}

?>